package com.platform.system.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.platform.system.entity.SysMenu;
import com.platform.system.mapper.SysMenuMapper;
import com.platform.system.service.SysMenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * describe:
 *
 * @author rainly
 * @date 2019/12/06
 * @time 11:31 下午
 */
@Slf4j
@Service
class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService {

    @Resource
    private SysMenuMapper sysMenuMapper;

    @Override
    public List<SysMenu> selectByParentId(String parentId) {
        return sysMenuMapper.selectByParentId(parentId);
    }

    @Override
    public List<SysMenu> selectMenuTree(String parentId) {
        List<SysMenu> menuTree = sysMenuMapper.selectByParentId(parentId);
        for (SysMenu menu : menuTree) {
            menu.setChildMenus(selectMenuTree(menu.getMenuId()));
        }
        return menuTree;
    }

    @Override
    public IPage<SysMenu> selectPageByParentId(Page<SysMenu> page, String parentId) {
        return sysMenuMapper.selectPageByParentId(page, parentId);
    }

}
